package com.keekus.common.dto.security;
import java.util.Comparator;
import java.util.List;

import org.springframework.security.core.GrantedAuthority;

import com.keekus.common.dto.BaseDTO;

public class Authority extends BaseDTO implements GrantedAuthority, Comparator<GrantedAuthority> {

	private static final long	serialVersionUID	= 7600778583250999439L;
	private String			id;
	private String			authorityName;

	private String			authorityDesc;

	private Boolean			isEnabled;

	private List<Resource>	resources;

	public String getAuthorityName() {
		return authorityName;
	}

	public void setAuthorityName(String authorityName) {
		this.authorityName = authorityName;
	}

	public String getAuthorityDesc() {
		return authorityDesc;
	}

	public void setAuthorityDesc(String authorityDesc) {
		this.authorityDesc = authorityDesc;
	}

	public Boolean getIsEnabled() {
		return isEnabled;
	}

	public void setIsEnabled(Boolean isEnabled) {
		this.isEnabled = isEnabled;
	}

	public List<Resource> getResources() {
		return resources;
	}

	public void setResources(List<Resource> resources) {
		this.resources = resources;
	}

	public Authority() {
		this.authorityName = null;
	}

	public Authority(String authorityName) {
		this.authorityName = authorityName;
	}



	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@Override
	public int compare(GrantedAuthority g1, GrantedAuthority g2) {
		if (g2.getAuthority() == null) {
			return -1;
		}
		if (g1.getAuthority() == null) {
			return 1;
		}
		return g1.getAuthority().compareTo(g2.getAuthority());
	}

	@Override
	public String getAuthority() {
		return authorityName;
	}

}